package com.happyass.dao;

import com.happyass.pojo.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public interface RoleDao extends PagingAndSortingRepository<Role,Integer>, JpaRepository<Role,Integer> {

    //修改权限
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(value="  update staff_role_rel set role_id = :roleId where staff_id = :staffId",nativeQuery = true)
    int updateRoleByStaffId(@Param("staffId") Integer staffId, @Param("roleId") Integer roleId);


}
